package com.hushow.plugin.tzdemo.controller;

import com.hushow.plugin.tzdemo.vo.response.*;
import com.hushow.plugin.tzdemo.vo.request.*;
import com.hushow.plugin.tzdemo.service.KctzService;
import org.springframework.web.bind.annotation.*;
import com.hucodex.rest.common.response.PageOutput;

import javax.annotation.Resource;
import java.util.List;
import javax.validation.Valid;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;

/**
 * (Kctz)表控制层
 *
 * @author hushowly
 * @since 2025-06-29 18:14:16
 */
@Api(value = "接口", tags = "")
@RestController
@RequestMapping("/kctz")
public class KctzController {

    /**
     * 服务对象
     */
    @Resource
    private KctzService kctzService;

    /**
     * 分页查询所有数据
     *
     * @param listReq 查询实体
     * @return 所有数据
     */
    @ApiOperation(value = "分页查询所有数据", notes = "分页查询所有数据")
    @PostMapping("/listKctzByPage")
    public PageOutput<ListKctzByPageResp> listKctzByPage(@RequestBody ListKctzByPageReq listReq) {
        return this.kctzService.listKctzByPage(listReq);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "通过主键查询单条数据", notes = "通过主键查询单条数据")
    @ApiImplicitParams(value = {@ApiImplicitParam(name = "id", value = "主键", required = true)})
    @GetMapping("/getKctzById")
    public KctzVo getKctzById(@RequestParam("id") String id) {
        return this.kctzService.getKctzById(id);
    }

    /**
     * 新增数据
     *
     * @param addReq 实体对象
     * @return 新增结果
     */
    @ApiOperation(value = "新增数据", notes = "新增数据")
    @PostMapping("/addKctz")
    public KctzVo addKctz(@RequestBody @Valid AddKctzReq addReq) {
        return this.kctzService.addKctz(addReq);
    }

    /**
     * 修改数据
     *
     * @param reqReq 实体对象
     * @return 修改结果
     */
    @ApiOperation(value = "修改数据", notes = "修改数据")
    @PutMapping("/updateKctz")
    public void updateKctz(@RequestBody @Valid UpdateKctzReq reqReq) {
        this.kctzService.updateKctz(reqReq);
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @ApiOperation(value = "删除数据", notes = "删除数据")
    @ApiImplicitParams(value = {@ApiImplicitParam(name = "idList", value = "主键集合", required = true)})
    @DeleteMapping("deleteKctzById")
    public Boolean deleteKctzById(@RequestParam("idList") List<Long> idList) {
        return this.kctzService.removeByIds(idList);
    }
}
